<?php
/**
 * Banner 控制层
 */

namespace api\controllers;

use api\models\ApiUpload;
use extensions\oss\Aliyun;
use Yii;
use api\components\ApiController;
use yii\web\UploadedFile;


class BannerController extends ApiController
{

    /** Oss 上传 */
    public function actionOssUpload()
    {
        $fields = ['isSave'];
        $params = $this->initParams(Yii::$app->request->post(), $fields);
        $uploadModel=new ApiUpload();
        $uploadModel->setScenario(ApiUpload::SCENARIO_UPLOAD);
        $uploadModel->load($params,'');
        $fielsInfo=UploadedFile::getInstanceByName('file');
        $uploadModel->file=$fielsInfo;
        $uploadModel->upload();
        return $this->message(-1, 'hello world', []);
    }

    public function actionTest()
    {
        Yii::$app->response->format = 'json';
        $response = Yii::$app->response;
        $response->data = ['code' => 100, 'data' => ['user' => 'zcy']];
        //return ['code' => 100, 'data' => ['user' => 'zcy']];
    }


}





